/**
 * 报表查询页面
 */
define(['apps/utils/tools'],function (tools){
   var domId = "content",tableId = "tableId",dimArr = [];
   function download(){
       var bean = tools.getDimParams(dimArr);
         tools.applyIf(bean,Utils.bean);
          var sub="?";
         for(var key in bean){
         	sub+=key+"="+bean[key]+"&";
         }
          var url = tools.getBasePathUrl()+"table/export.cnbi"+sub;
          tools.console(url);
          window.location.href=url;
   }
   /**
    * 导出excel文件按键事件绑定
    */
    function exportBind(){
     $("#btnGroup >a").bind("click",function(){
         var id = $(this).attr("id");
         if(id== "exportExl"){
            download();
         }else{//$("p").fadeToggle("slow","linear");
           var id = $(this).attr("scode");
            $("#"+id).fadeToggle("slow","linear").siblings().fadeToggle("slow","linear");
         }
     });	
    /* $("#exportExl").bind("click",function(){
         download();
     });*/
   }
   /**
    * index.cnbi成功事件
    */
   function success(msg){
		tools.levelNav(Utils.bean);
		msg = tools.getTableDatas(msg);
		$("#"+domId).empty().append(msg);
		tools.viewChange();
		tools.dimComponentClick(Utils.dimMapJson);
		exportBind();
		dimArr = tools.getDimArrByMap(Utils.dimMapJson);//dblclick
		tools.bindPanelHeaderDbClick();
		tools.unmask();
   }
   /** 
   * 初始方法
   */
  function init (){
  	  tools.eventBind({domId:domId,tableId:tableId,success:success});
   }
  return {
    init: init
  }
});